<template>
<el-dialog
  title="历史转派记录"
  :visible.sync="dialogVisible"
  :before-close="handleClose"
  width="50%"
  v-dialogDrag
  append-to-body
  custom-class="m-view-dialogSrmMaterialsPurchaser"
  :close-on-click-modal="false"
  :close-on-press-escape="false">
    <div class="m-agTableModel"  v-loading="loadingDia" style="padding-bottom: 25px; margin-top: -10px">
      <ag-grid-component
        ref="agGridComponent"
        :tableName="'dialogSrmHistoryLog'"
        :getGridOptions="gridOptions"
        v-loading="false"
        class="m-agTableModel ag-theme-balham"
        :getColumnDefs="columnDefs"
        :isColFit="true"
        :systemInfo="$systemInfo"
      ></ag-grid-component>
    </div>
  </el-dialog>
</template>
<script>
import agGridComponents from "@/components/agGridComponents.js";
import _Api from "@/api";
import localeText from "@/i18n/agGridText";

/**
 * @group dialogSrmHistoryLog
 * 转派历史记录弹窗
 */
export default {
  name: 'dialogSrmHistoryLog',
  components:{
		agGridComponents
	},
  props:{
    //显示弹框
    dialogVisible: {
      //类型布尔值
      type: Boolean,
      //默认值是true
      default: true
    },
    //传进来的查询数据
    formData: {
      //类型布尔值
      type: Object,
      //默认值是true
      default: {}
    }
  },
  data(){
    return {
			//表格参数
			gridOptions: '',
      columnDefs: [],
      loadingDia: false
    }
  },
  beforeMount () {
		this.gridOptions = {
		  context: {
        componentParent: this
      },
      enableColResize: true,
      localeText: localeText,
      suppressRowClickSelection: true,//单元格选中,false为选中整行
		};
		this.columnDefs = [
			{	headerName: "原任务号", field: "taskNo", width: 120},
      { headerName: "原责任人", field: "handlerName", width: 120 },
      { headerName: "转派时间", field: "modifyDate", width: 160 },
      { headerName: "新责任人", field: "chandlerName", width: 120 }
    ];
  },
  methods: {
    /**
		 * @vuese
		 * 查看转派历史
		 * 
		 * @arg row:行数据;
		 */
		getHistoryLog( ){
			let param = {
				requestNo: this.formData.requestNo,
				requestMxno: this.formData.requestMxno
			}
			this.loadingDia = true;
			_Api
				.getTaskHistoryLog(param)
				.then(res => {
					this.loadingDia = false;
					if (res.data.code == 1) {
					  this.$refs.agGridComponent.gridOptions.api.setRowData(res.data.rows);
					} else {
						this.$alert(res.data.info, { showClose: false, confirmButton: "确定", customClass: "alertFailure" });
					}
				})
				.catch(err => {
					this.loadingDia = false;
					this.$alert(err.data.info, { showClose: false, confirmButton: "确定", customClass: "alertFailure" });
				});
		},
    /**
     * @vuese
     * 关闭对话框回调
     */
    handleClose() {
      this.$emit("dialogClose", false);
    }
  },
  watch:{
    dialogVisible( value ){
      if(value){
        this.getHistoryLog();
      }
    } 
  }
}
</script>

<style lang="less">
.m-view-dialogSrmMaterialsPurchaser{
  .el-form-item{
    margin-bottom: 0;
  }
}
</style>